<template>
	<div class="my">
		<div v-for="(item, index) in baseInfo.Configs" :key="index">
			<div v-if="item.Type">
				<van-field name="area" v-if="item.Type == 'Text' || item.Type == 'Number'" v-model="item.Value"
					:label="item.Display">
					<template #extra>
						{{ item.Unit }}
					</template>
				</van-field>
				<van-field class="input_text" v-if="item.Type == 'Choose'" v-model="trade" :label="item.Display" readonly
					autosize type="textarea" />
				<!-- 单选框 -->
				<van-field class="input_text" :label="item.Display" v-if="item.Type == 'Radio'" :border="false">
					<template #input>
						<van-radio-group v-model="item.Value" direction="horizontal">
							<van-radio v-for="(item1, index1) in item.ParamList" :key="index1" :name="item1.ID"
								style="margin:10px 10px 0 0">{{ item1.Name }}</van-radio>
						</van-radio-group>
					</template>
				</van-field>

				 <van-field v-model="item.RelatedFieldValue"
					v-if="item.Type == 'Radio' && item.Value == 'T' && item.ShowRelatedFieldKey" label=" ">
					      <template #extra>
						        {{ item.RelatedFieldUnit }}
						    </template>
					    </van-field>
			</div>
		</div>

		<div class="btn_submit">
			<van-button class="br-5" block type="info" @click="save">
				保存
			</van-button>
		</div>
	</div>
</template>

<script>
import { GetQueryupText, updateModifyPostNew } from '@/api/base'
import { mapGetters } from 'vuex'
export default {
	components: {},
	data() {
		return {
			loading: false,
			mobile: '',
			message: '',
			value: '',
			uploader: [{ url: 'https://img.yzcdn.cn/vant/leaf.jpg' }],
			showCalendar: false,
			value1: '',
			showArea: false,
			areaList: {}, // 数据格式见 Area 组件文档
			radio: '1',
			baseInfo: this.$route.params,
			trade: '',
		}
	},
	computed: {
		...mapGetters(['baseUrl','CompanyCode']),
	},
	created() {
		console.log(this.$route.params, 'params')
		const baseInfo = this.$route.params
		if (baseInfo.Configs) {
			baseInfo.Configs.forEach((item1) => {
				if (item1.FieldName == 'ApplyProfession') {
					this.GetQueryupText(item1.Value)
				}
			})
		}
	},
	methods: {
		// 行业信息  UserManager 本页没有行业项
		GetQueryupText(value) {
			this.loading = true
			GetQueryupText({ value })
				.then((res) => {
					this.loading = false
					this.trade = res.data
					console.log(this.trade, 'this.trade')
				})
				.catch((err) => {
					console.log('err', err)
				})
		},

		save() {
			console.log(this.CompanyCode)
			this.loading = true
			let params = {}
			params.CompanyCode=this.CompanyCode
			this.baseInfo.Configs.forEach(item => {
				params[item.FieldName] = item.Value
				if (item.ShowRelatedFieldKey) {
					params[item.RelatedFieldName] = item.RelatedFieldValue
				}
			})
			this.$axios.post("/UserEnterprise/ModifyPostNew?key=Manager",params).then((res)=>{
				this.loading = false
				this.$router.go(-1)
			}).catch((err) => {
					console.log('err', err)
				})

		},
	},
}
</script>

<style lang="less"></style>
